package me.cxlr.qinlauncher2.view.settings;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import androidx.preference.DropDownPreference;
import androidx.preference.PreferenceFragmentCompat;

import me.cxlr.qinlauncher2.R;
import me.cxlr.qinlauncher2.util.ThemeUtil;
import me.cxlr.qinlauncher2.util.ToastUtil;

/**
 * @author 酷安用户:山轮纸
 */
public class AboutAuthorFragment extends PreferenceFragmentCompat {

    @Override
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        setPreferencesFromResource(R.xml.preferences_about_author_settings, rootKey);

        // 开源网址
        DropDownPreference openSource = findPreference("open_source");
        assert openSource != null;
        openSource.setOnPreferenceClickListener(preference -> {
            try {
                requireActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://gitee.com/shanlunzhi/qin-launcher")));
            } catch (Exception e) {
                ToastUtil.show(requireContext(), "未找到浏览器App", ToastUtil.LENGTH_LONG);
            }
            return true;
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        ThemeUtil.initTheme();
    }
}